CREATE OR REPLACE FUNCTION func_add_column() RETURNS void AS $$
DECLARE
    VCOUNT  INTEGER := 0;
BEGIN
  SELECT count(*) into VCOUNT FROM pg_attribute WHERE attrelid='<SCHEMA>.jms_monit_message'::REGCLASS AND attname = 'ts_msg_put';
  IF VCOUNT = 0 THEN
    ALTER TABLE <SCHEMA>.jms_monit_message ADD ts_msg_put TIMESTAMP;
  END IF;
  RETURN;
END;
$$ LANGUAGE plpgsql;
SELECT func_add_column();
DROP FUNCTION func_add_column();

COMMENT ON COLUMN <SCHEMA>.jms_monit_message.ts_msg_put is 'TIMESTAMP NA QUAL A MENSAGEM POSTADA NA FILA.';
